#用程序模拟这个过程就可以完成，比较基础

def jm(sequence, n):
    for _ in range(n):
        new_seq = ''
        count = 1
        for i in range(1, len(sequence) + 1):
            if i < len(sequence) and sequence[i] == sequence[i - 1]:
                count += 1
            else:
                new_seq += str(count) + sequence[i - 1]
                count = 1
        sequence = new_seq
    return sequence
qs=input().strip()
bh=int(input().strip())
print(jm(qs,bh))